/*

This file is part of roomyak.

Copyright (C) 2008 Pixecur Technologies Incorporated (Esotera).
Visit Esotera at http://www.esoteras3.com
 
roomyak is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
 
roomyak is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with roomyak; see the file COPYING.  If not, write to 
Pixecur Technologies, 213-31 Peet Street, St. John's, NL, A1B 3W8. 
 
Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
 
*/

package com.datasentinel.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;

/**
 * 
 * This type encapsulates the text/uri-list internet media type as defined in
 * RFC 2483 (http://rfc.net/rfc2483.html)
 * 
 * This type is used to handle drag and drop events in Linux-based user
 * interfaces such as GNOME et al.
 * 
 * @author rickp
 * 
 */
@SuppressWarnings("serial")
public class URIList extends ArrayList<URI>
{
	public URIList(String textURIList) throws URISyntaxException
	{
		BufferedReader br = null;
		try
		{
			br = new BufferedReader(new StringReader(textURIList));
			String s = null;
			while ((s = br.readLine()) != null)
			{
				if (!s.trim().startsWith("#"))
					add(new URI(s));
			}
		}
		catch (IOException ioe)
		{
		}
		finally
		{
			if (br instanceof BufferedReader)
			{
				try
				{
					br.close();
				}
				catch (IOException ioe)
				{
				}
				;
			}
		}
	}
}
